import service from "@/server/serviceIndex";

// 网店首级分类标签列表展示
export const topCateList = (categoryPid) => {
  return service({
    method: "get",
    url: `/pipayshopapi/category/selectAllCategory/${categoryPid}`,
  });
};

// 网店首页条件过滤列表展示
export const itemSearchCommodity = (data) => {
  return service.post('/pipayshopapi/commodity/listCommodity', data);
};


// 网店首页轮播图
export const selectBgImgList = (params) => {
  return service({
    method: "get",
    url: `/pipayshopapi/bg-img/selectBgImgList/${params}`,
  });
};

// 网店二级分类标签数据
export const secondCateList = (categoryPid) => {
  return service({
    method: "get",
    url: `/pipayshopapi/category/selectAllCategory/${categoryPid}`,
  });
};

// 网店二级分类标签下的商品数据
export const commodityOfCateList = (data) => {
  return service.post('/pipayshopapi/commodity/listCommodity', data);
};

// 网店商品详情数据
export const itemCommodityDetail = (commodityId) => {
  return service({
    method: "get",
    url: `pipayshopapi/commodity/itemCommodityDetail/${commodityId}`,
  });
};

// 用户关注网店接口
export const userFollowItem = ({ followId, itemId }) => {
  return service({
    method: "post",
    url: `/pipayshopapi/followfocus/userFollowShop/${followId}/${itemId}`,
  });
};

// 用户取关网店接口
export const userUnfollow = ({ followId, itemId }) => {
  return service({
    method: "post",
    url: `/pipayshopapi/followfocus/userFollowShop/${followId}/${itemId}`,
  });
};

// 查询用户是否已经关注该网店
export const isItemFollow = (shopId,userId ) => {
  return service({
    method: "get",
    url: `/pipayshopapi/followfocus/isFollowShop/${shopId}/${userId}`,
  });
};

// 查询网店粉丝总数接口
export const itemFansSum = (itemId) => {
  return service({
    method: "get",
    url: `/pipayshopapi/followfocus/shopFansSum/${itemId}`,
  });
};

// 网店商品收藏新增接口
export const AddItemCommodityToCollection = ({ userId, commodityId }) => {
  return service({
    method: "post",
    url: `/pipayshopapi/collection/AddShopCommodityToCollection/${userId}/${commodityId}`,
  });
};

// 网店商品收藏删除接口
export const closeItemCommodityToCollection = ({ userId, commodityId }) => {
  return service({
    method: "post",
    url: `/pipayshopapi/collection/closeShopCommodityToCollection/${userId}/${commodityId}`,
  });
};

// 校验该网店商品是否已经被收藏接口
export const isItemCommodityToCollection = ({ userId, commodityId }) => {
  return service({
    method: "get",
    url: `/pipayshopapi/collection/isShopCommodityToCollection/${userId}/${commodityId}`,
  });
};

// 网店首页获取品牌的集合
export const itemSelectAllBrandList = () => {
  return service({
    method: "get",
    url: `/pipayshopapi/brand-info/itemSelectAllBrandList`,
  });
};

// 获取某网店商品列表
export const getItemComData = ({ itemId, page, limit, price }) => {
  return service({
    method: "get",
    url: `/pipayshopapi/shop/getItemInfo/${itemId}/${page}/${limit}/${price}`,
  });
};

// 获取某网店评论列表
export const getItemEvaluate = ({ itemId, page, limit }) => {
  return service({
    method: "get",
    url: `/pipayshopapi/shop/getShopEvaluate/${itemId}/${page}/${limit}`,
  });
};

//店铺
export const getShopInfoByShopidApi = (shopId) => {
  return service({
    method: "get",
    url: `/pipayshopapi/shop/getShopInfoByShopid/${shopId}`,
  });
};



// 加入购物车
export const putItemCartById = (putItemCartReq) => {
  return service({
    method: "post",
    url: '/pipayshopapi/shopcart/addShopCart',
    data:putItemCartReq,
    headers: {
      'Content-Type': 'application/json',
  }
  });
};

// 生成未支付订单 (积分)
export const generateUnpaidItemOrder = (token) => {
  return service({
    method: "post",
    url: `/pipayshopapi/order/generateUnpaidOrder`,
    params: {
      token,
    },
  });
};

// 生成未支付订单（pi支付）
export const generateUnpaidOrderByPi = (token) => {
  return service({
    method: "post",
    url: `/pipayshopapi/order/generateUnpaidOrderByPi?token=${token}`,
  });
};

// 支付下单接口
export const payItemOrder = (token) => {
  return service({
    method: "post",
    url: `/pipayshopapi/order/payOrder?token=${token}`,
  });
};

// 订单（未支付 / 已支付）的详情接口
export const getItemOrderDetail = (orderId) => {
  return service({
    method: "get",
    url: `/pipayshopapi/order/getOrderDetail/${orderId}`,
  });
};

// pi支付上传凭证
export const payOrderCertificate = (token, data) => {
  return service({
    method: "post",
    url: `/pipayshopapi/item-order/payOrderCertificate?token=${token}`,
    headers: { "Content-Type": "multipart/form-data" },
    data,
  });
};

//获取规格
export const getListSku= (categoryId) => {
  return service({
    method: "get",
    url: `/pipayshopapi/sku/listSku/${categoryId}`,
  });
};
